//
//  UFOLQCWebViewController.m
//  unrivalledForUniverse
//
//  Created by dllo on 1/12/16.
//  Copyright © 2016 dllo. All rights reserved.
//

#import "UFOLQCWebViewController.h"

@interface UFOLQCWebViewController ()<UIWebViewDelegate>
@property (nonatomic, retain)UIWebView *webView;
@end

@implementation UFOLQCWebViewController

- (void)dealloc
{
    self.webView.delegate = nil;
    [_url release];
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.webView = [UIWebView new];
    
    [self.webView setUserInteractionEnabled:YES];
    
    self.webView.delegate = self;
    
    self.webView.opaque = NO;
    
    self.webView.scalesPageToFit = YES;
    
    [self.view addSubview:self.webView];
    
    [self.webView release];
    
    NSURL *url = [[NSURL alloc] initWithString:self.url];
    
    
    [self.webView loadRequest:[NSURLRequest requestWithURL:url]];
    
    UIButton *button = [UIButton new];
    button.backgroundColor = [UIColor blueColor];
    [button setTitle:@"<" forState:UIControlStateNormal];
    [button addTarget:self action:@selector(buttonAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
    
    UILabel *label = [UILabel new];
    label.backgroundColor = [UIColor blueColor];
    label.text = @"咨询详情";
    label.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:label];
    
    UIButton *buttonF = [UIButton new];
    buttonF.backgroundColor = [UIColor blueColor];
    [buttonF setTitle:@"@" forState:UIControlStateNormal];
    [self.view addSubview:buttonF];
    
    [self.webView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.right.equalTo(self.view).offset(0);
        make.top.equalTo(self.view).offset(60);
        
    }];
    
    [button mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(0);
        make.bottom.equalTo(self.webView.mas_top).offset(0);
        make.right.equalTo(label.mas_left).offset(0);
        make.top.equalTo(self.view).offset(20);
        make.width.mas_equalTo(@50);
    }];
    
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.webView.mas_top).offset(0);
        make.top.equalTo(self.view).offset(20);
    }];
    
    [buttonF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(label.mas_right).offset(0);
        make.bottom.equalTo(self.webView.mas_top).offset(0);
        make.right.equalTo(self.view).offset(0);
        make.top.equalTo(self.view).offset(20);
        make.width.mas_equalTo(@50);
    }];
}

- (void)buttonAction
{
    [self dismissViewControllerAnimated:YES completion:^{
        
        
    }];
    
}

- (void)webViewDidStartLoad:(UIWebView *)webView{
    
}

- (void)webViewDidFinishLoad:(UIWebView *)web{
    
}

-(void)webView:(UIWebView*)webView  DidFailLoadWithError:(NSError*)error{
     
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
